package com.sojson.entity.bo;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.sojson.entity.po.Menu;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * Treeselect树结构实体类
 * 
 * @author liu
 * @date 2021-05-18
 */
@ApiModel("下拉列表Bean")
public class TreeSelect implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("节点ID")
    private Integer id;
    @ApiModelProperty("节点名称")
    private String label;
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    @ApiModelProperty("子节点")
    private List<TreeSelect> children;

    public TreeSelect() {

    }

    public TreeSelect(Menu menu) {
        this.id = menu.getId();
        this.label = menu.getName();
        this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public List<TreeSelect> getChildren() {
        return children;
    }

    public void setChildren(List<TreeSelect> children) {
        this.children = children;
    }
}
